package com.mxf.code.controller;

import com.mxf.code.response.LocationListResponse;
import com.mxf.code.response.LocationListWithTreeResponse;
import com.mxf.code.service.SpaceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;


/**
 * 空间位置管理
 *
 * @author mxf
 * @since 3.0 2022-11-09
 */
@RestController
@RequestMapping("app/gspace")
@Api(tags = "空间位置管理")
public class SpaceController {

    @Autowired
    private SpaceService spaceService;

    @GetMapping("getAllLevelSpace/{id}")
    @ApiOperation("获取完整层次空间名称")
    public String getAllLevelSpace(@PathVariable("id") Long id) {
        return spaceService.getAllLevelSpace(id);
    }

    @GetMapping("tree")
    @ApiOperation("查询位置分类树状")
    public List<LocationListWithTreeResponse> getTree() {
        return spaceService.locationListWithTree();
    }

    @GetMapping("list")
    @ApiOperation("查询位置分类列表")
    public Map<String, LocationListResponse> getList() {
        return spaceService.getAllLevelSpace();
    }

    @GetMapping("{id}")
    @ApiOperation("获取完整层次空间名称")
    public String getAllLevelSpaceById(@PathVariable("id") Long id) {
        return spaceService.getAllLevelSpaceById(id);
    }
}
